package com.leyou.auth.utils;

import com.leyou.auth.dto.UserDetails;

/**
 * @author 虎哥
 */
public class UserContext {
    /**
     * 存储用户
     */
    private static final ThreadLocal<UserDetails> tl = new ThreadLocal<>();
    /**
     * 存储JWT
     */
    private static final ThreadLocal<String> tl2 = new ThreadLocal<>();


    public static void setJwt(String jwt){
        tl2.set(jwt);
    }

    public static String getJwt(){
        return tl2.get();
    }

    public static void removeJwt(){
        tl2.remove();
    }

    public static void setUser(UserDetails user){
        tl.set(user);
    }

    public static UserDetails getUser(){
        return tl.get();
    }

    public static void removeUser(){
        tl.remove();
    }
}
